import 'package:dio/dio.dart';

class RandomText {
  String hitokoto;
  String from;

  RandomText(this.hitokoto, this.from);
}

class RandomTextService {
  static Future<RandomText> randomText() async {
    var dio = Dio(
      BaseOptions(
        headers: {
          'User-Agent':
              'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
        },
      ),
    );
    var res = await dio.get('https://api.codelife.cc/yiyan/random?lang=cn');
    return RandomText(res.data['data']['hitokoto'], res.data['data']['from']);
  }
}
